package org.xteam.box2text.old;

import java.util.Arrays;
import java.util.List;
import java.util.Map;

import org.xteam.box2text.Frame;
import org.xteam.box2text.Line;
import org.xteam.box2text.Point;
import org.xteam.box2text.TextStruct;

public class WDOperator extends Operator implements IPlaceableBox {

	public WDOperator(int hs, List<Box> arguments) {
		super(arguments);
		options.put("hs", hs);
	}
	
	public WDOperator(Box... arguments) {
		super(arguments);
	}
	
	public WDOperator(Map<String, Integer> options, List<Box> arguments) {
		super(options, arguments);
	}

	public Box removeVertical(boolean removeRow) {
		return new WDOperator(options, removeVertical(arguments, removeRow));
	}

	public int width(Frame frame) {
		return width(arguments, frame);
	}
	
	@Override
	public List<Box> normalizeGroups(boolean splice) {
		return Arrays.asList(new Box[] { new WDOperator(options, normalizeChildren(true)) });
	}

	public TextStruct place(Frame frame, TextStruct textStruct, int context) {
		TextStruct ts = new HOperator(0, arguments).place(frame, textStruct, context);
        return new TextBox(new Line(ts.x() - frame.x())).place(frame, textStruct, context);
	}

	public Point length(Frame frame, int context) {
		Point bp = length(arguments, frame, context);
		return new Point(bp.width(), 0);
	}

}
